<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<base href="http://localhost:8080/book/">
<div id="page_nav">
    <c:if test="${requestScope.page.pageNo>1}">
        <a href="${requestScope.page.url}&pageNo=1">首页</a>
        <a href="${requestScope.page.url}&pageNo=${page.pageNo-1}">上一页</a>
    </c:if>
    <c:choose>
        <%--    //总页数在5页内 全部显示--%>
        <c:when test="${requestScope.page.pageTotal<=5}">
            <c:set var="begin" value="1"/>
            <c:set var="end" value="${requestScope.page.pageTotal}"/>
        </c:when>
        <%--    //总页大于5页 --%>
        <c:when test="${requestScope.page.pageTotal>5}">
            <c:choose>
                <%--        总页大于5页  小情况1:当前页面为前三个 页码范围在1-5--%>
                <c:when test="${requestScope.page.pageNo<=3}">
                    <c:set var="begin" value="1"/>
                    <c:set var="end" value="5"/>
                </c:when>
                <%--        总页大于5页  小情况2:当前页面为后三个 页码范围在最后1-5--%>
                <c:when test="${requestScope.page.pageNo>requestScope.page.pageTotal-3}">
                    <c:set var="begin" value="${requestScope.page.pageTotal-4}"/>
                    <c:set var="end" value="${requestScope.page.pageTotal}"/>
                </c:when>
                <%--        总页大于5页  小情况3:其余情况--%>
                <c:otherwise>
                    <c:set var="begin" value="${requestScope.page.pageNo-2}"/>
                    <c:set var="end" value="${requestScope.page.pageNo+2}"/>
                </c:otherwise>
            </c:choose>
        </c:when>
    </c:choose>
    <c:forEach begin="${begin}" end="${end}" var="b5" >
        <c:if test="${b5==requestScope.page.pageNo}">
            [<a href="${requestScope.page.url}&pageNo=${b5}">${b5}</a>]
        </c:if>
        <c:if test="${requestScope.page.pageNo!=b5}">
    <a href="${requestScope.page.url}&pageNo=${b5}">${b5}</a>
        </c:if>
    </c:forEach>
    <c:if test="${requestScope.page.pageNo<requestScope.page.pageTotal}">
        <a href="${requestScope.page.url}&pageNo=${page.pageNo+1}">下一页</a>
        <a href="${requestScope.page.url}&pageNo=${page.pageTotal}">末页</a>
    </c:if>
    共${requestScope.page.pageTotal}页，${requestScope.page.pageTotalcount}条记录 到第<input value="${requestScope.page.pageNo}" name="pn" id="pn_input"/>页
    <input id="bottommm" type="button" value="确定">

</div>